﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace VideoCache.Server.MVCWeb.Attributes
{
    public class VerifyCodeAttribute : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            HttpContext httpContext = HttpContext.Current;

            if (httpContext.Session[Constans.VerifyCode] == null) return false;

            string verifyCode = httpContext.Session[Constans.VerifyCode].ToString();

            if (value.ToString() == verifyCode)
            {
                return true;
            }

            return false;
        }
    }
}